<?php 
$width = param('width');
		$data = param('data', '', FALSE);
		empty($data) AND message(-1, lang('data_is_empty'));
		$data = base64_decode_file_data($data);
		$size = strlen($data);

		$filename = time().".png";
		$dir = 'attach/'.date("Ym").'/';
		$path = $conf['upload_path'].$dir;
		$url = $conf['upload_url'].$dir.$filename;
		!is_dir($path) AND (mkdir($path, 0777, TRUE) OR message(-2, lang('directory_create_failed')));
		file_put_contents($path.$filename, $data) OR message(-1, lang('write_to_file_failed'));
		message(0, array('url'=>$url));


 ?>